|
|
|
|
|
|
|
Figure 15.12
Program Depth2 displaying a seriously
nonconvex stellate icosahedron. |
|
|
|
|
|
|
|
|
You can see that ordering polygons is a complicated process full of special cases. The tests that handle these cases are arranged so that the tests that are fastest and most likely to give conclusive results are performed first. More time-consuming tests, like those used by function Obscures, are performed only if absolutely necessary. |
|
|
|
|
|
|
|
|
Example program Depth2, shown in Figure 15.12, uses these routines to display nonconvex solids. Use the option buttons to select a solid to view. Use the Hide Surface check box to tell the program to use the Depth-Sort algorithm to remove the hidden surfaces. |
|
|
|
|
|
|
|
|
Chapter 14, Surfaces, describes ways you can create and display different kinds of three-dimensional surfaces. It also explains the hi-lo and Z-order algorithms for performing hidden surface removal for many kinds of simple surfaces. Unfortunately, this algorithm is not guaranteed to work for all perspective transformations. It also does not handle more complex surfaces like Bezier surfaces, B-splines, and surfaces of transformation. You can use the Depth-Sort algorithm to perform hidden surface removal in these other situations. |
|
|
|
|
|
|
|
|
Before you can use Depth-Sort, you must make a few changes to the way you store surfaces. The programs described in Chapter 14 create and store surfaces as collections of polyline objects. This is fine for displaying a skeleton view of a surface, but the Depth-Sort algorithm works only with polygons. To display these surfaces using Depth-Sort, you must first modify the programs to generate surface polygons. |
|
|
|
|
|
|
|
|
Many of the surfaces described in Chapter 14 are made up of areas that are not flat polygons. Bezier surfaces, B-splines, and surfaces of transformation all consist of some sort of bent rectangle or quadrilateral. The easiest way to convert a bent quadrilateral into a group of polygons is to break it into two triangles, as shown in Figure 15.13. With this strategy in mind, you can modify the programs that generate these surfaces so that they produce triangles rather than bent quadrilaterals. |
|
|
|
|
|